1.
To find no of records in table
var g= new GlideAggregate('incident');
g.addAggregate('COUNT');
g.query();
var incident= 0;
if(g.next()){
incident= g.getAggregate("COUNT");
}
gs.print('The Number of incidents are='+incident);
2.
To find no of incidents with caller Pallavi using addEncodedQuery
var g= new GlideAggregate('incident');
g.addEncodedQuery('caller_id=681ccaf9c0a8016400b98a06818d57c7');//Sys_id of
Pallavi
g.addAggregate('COUNT');
g.query();
var incident=0;
if(g.next()){
incident=g.getAggregate('COUNT');
}
gs.print('Number of incidents with caller Pallavi='+incident);
3.
To find no of incidents where assigned to field is not empty
var g=new GlideAggregate('incident');
g.addNotNullQuery('assigned_to');
g.addAggregate('COUNT');
g.query();
var incident=0;
while(g.next()){
incident=g.getAggregate('COUNT');
}
gs.print('number of incident where assigned to field is not
empty='+incident);
4.
To find no of incidents where assigned to field is empty
var g=new GlideAggregate('incident');
g.addNullQuery('assigned_to');
g.addAggregate('COUNT');
g.query();
var incident=0;
while(g.next()){
incident=g.getAggregate('COUNT');
}
gs.print('number of incident where assigned to field is empty='+incident);
5.
To find number of incidents with state new
var g=new GlideAggregate('incident');
g.addQuery('state', '1');
g.addAggregate('COUNT');
g.query();
var incident=0;
while(g.next()){
incident=g.getAggregate('COUNT');
}
gs.print('number of incident with state new='+incident);
6.
To find number of incidents active true
var g=new GlideAggregate('incident');
g.addQuery('active', 'true');
g.addAggregate('COUNT');
g.query();
var incident=0;
while(g.next()){
incident=g.getAggregate('COUNT');
}
gs.print('number of incidents='+incident);
7.
To find no of incidents with different category
var g =new GlideAggregate('incident');
g.addQuery('active','true');
g.addAggregate('COUNT','category');
g.query();
while(g.next()){
category = g.category;
categoryCount = g.getAggregate('COUNT','category');
}
gs.log("The are currently "+ categoryCount +" incidents with a category of
"+ category);lideAggregate('incident');
g.addAggregate('COUNT');
g.query();
var incident= 0;
if(g.next()){
incident= g.getAggregate("COUNT");
}
gs.print('The Number of incidents are='+incident);
8.
To find no of incidents with caller Pallavi using addEncodedQuery
var g= new GlideAggregate('incident');
g.addEncodedQuery('caller_id=681ccaf9c0a8016400b98a06818d57c7');//Sys_id of
Pallavi
g.addAggregate('COUNT');
g.query();
var incident=0;
if(g.next()){
incident=g.getAggregate('COUNT');
}
gs.print('Number of incidents with caller Pallavi='+incident);
9.
To find no of incidents where assigned to field is not empty
var g=new GlideAggregate('incident');
g.addNotNullQuery('assigned_to');
g.addAggregate('COUNT');
g.query();
var incident=0;
while(g.next()){
incident=g.getAggregate('COUNT');
}
gs.print('number of incident where assigned to field is not
empty='+incident);
10.
To find no of incidents where assigned to field is empty
var g=new GlideAggregate('incident');
g.addNullQuery('assigned_to');
g.addAggregate('COUNT');
g.query();
var incident=0;
while(g.next()){
incident=g.getAggregate('COUNT');
}
gs.print('number of incident where assigned to field is empty='+incident);
11.
To find number of incidents with state new
var g=new GlideAggregate('incident');
g.addQuery('state', '1');
g.addAggregate('COUNT');
g.query();
var incident=0;
while(g.next()){
incident=g.getAggregate('COUNT');
}
gs.print('number of incident with state new='+incident);
12.
To find number of incidents active true
var g=new GlideAggregate('incident');
g.addQuery('active', 'true');
g.addAggregate('COUNT');
g.query();
var incident=0;
while(g.next()){
incident=g.getAggregate('COUNT');
}
gs.print('number of incidents='+incident);
13.
To find no of incidents with different category
var g =new GlideAggregate('incident');
g.addQuery('active','true');
g.addAggregate('COUNT','category');
g.query();
while(g.next()){
category = g.category;
categoryCount = g.getAggregate('COUNT','category');
}
gs.log("The are currently "+ categoryCount +" incidents with a category of
"+ category);